import { createSelector } from "@ngrx/store";
import { getMapState } from "./map.selector";
import { MapState, SpatialQueryState, SpatialQueryType } from "../reducers";


export const getSpatialQueryState = createSelector(getMapState, (state: MapState) => state.spatialQuery);

export const getSpatialQuerySelect = createSelector(getSpatialQueryState, (state: SpatialQueryState) => state.select);

export const getSpatialQueryRemove = createSelector(getSpatialQueryState, (state: SpatialQueryState) => !!state.remove);

export const getSpatialQueryClean = createSelector(getSpatialQueryState, (state: SpatialQueryState) => !!state.clean);

export const getSpatialQueryRemoveUsable = createSelector(getSpatialQueryState, (state: SpatialQueryState) => state.removeUsable);

export const getSpatialQueryCleanUsable = createSelector(getSpatialQueryState, (state: SpatialQueryState) => state.cleanUsable);

export const getSpatialQueryType = createSelector(getSpatialQueryState, (state: SpatialQueryState) => state.type);

export const getSpatialQueryPoint = createSelector(getSpatialQueryType, (type: SpatialQueryType) => type === SpatialQueryType.POINT);

export const getSpatialQueryLine = createSelector(getSpatialQueryType, (type: SpatialQueryType) => type === SpatialQueryType.LINE);

export const getSpatialQueryCircle = createSelector(getSpatialQueryType, (type: SpatialQueryType) => type === SpatialQueryType.CIRCLE);

export const getSpatialQueryRectangle = createSelector(getSpatialQueryType, (type: SpatialQueryType) => type === SpatialQueryType.RECTANGLE);

export const getSpatialQueryPolygon = createSelector(getSpatialQueryType, (type: SpatialQueryType) => type === SpatialQueryType.POLYGON);
